with open('./bil.txt','r+',encoding='utf-8')as f,open('./bil.txt.bak','w',encoding='utf-8')as f_bak:
    res = f.read()
    f_bak.write(res)

    #内容删除
    s = ""
    for line in res.split('\n'):
        if line.find('测试') == -1:
            s += line + '\n'

    #回转指针
    f.seek(0)
    #清空内容
    f.truncate(f_bak)

    #写入新内容
    f.write(s)


print()

